//
//  LEMyTableCell.m
//  qqqqqq
//
//  Created by iOSer on 2017/3/16.
//  Copyright © 2017年 iOSer. All rights reserved.
//

#import "LEMyTableCell.h"
#import "LEOwnCommodityModel.h"
@interface LEMyTableCell()
@property(nonatomic,strong) UILabel *nameLab;
@property(nonatomic,strong) UILabel *priceLab;
@property(nonatomic,strong) UILabel *countLab;
@end
@implementation LEMyTableCell

+(instancetype)LEMyTableCellWithTableView:(UITableView *)tableView{
    static NSString * ID = @"LEMyTableCell";
    LEMyTableCell* cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[LEMyTableCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}
-(void)setModel:(LEOwnCommodityModel *)model{
    _model = model;
    self.nameLab.text = model.name;
    self.priceLab.text = [NSString stringWithFormat:@"￥%ld",model.costing];
    self.countLab.text = [NSString stringWithFormat:@"%d",model.count];
}
-(void)setupUI{
    [self.contentView addSubview:self.nameLab];
    [self.contentView addSubview:self.priceLab];
    [self.contentView addSubview:self.countLab];
    [_nameLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self.contentView);
        make.width.equalTo((SCREEN_WIDTH/2-40)/3);
    }];
    [_priceLab makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_nameLab.mas_right);
        make.top.bottom.equalTo(self.contentView);
        make.width.equalTo((SCREEN_WIDTH/2-40)/3);
    }];
    [_countLab makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(self.contentView);
        make.width.equalTo((SCREEN_WIDTH/2-40)/3);
    }];
}
-(UILabel *)nameLab{
    if (!_nameLab) {
        _nameLab = [[UILabel alloc] initWithTitle:@"脚丫子" color:HEXColor(0x000000, 1) sizeFont:GGRealValue(10)];
        _nameLab.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLab;
}
-(UILabel *)countLab{
    if (!_countLab) {
        _countLab = [[UILabel alloc] initWithTitle:@"50" color:HEXColor(0x000000, 1) sizeFont:GGRealValue(10)];
        _countLab.textAlignment = NSTextAlignmentCenter;
    }
    return _countLab;
}
-(UILabel *)priceLab{
    if (!_priceLab) {
        _priceLab = [[UILabel alloc] initWithTitle:@"￥2" color:HEXColor(0x000000, 1) sizeFont:GGRealValue(10)];
        _priceLab.textAlignment = NSTextAlignmentCenter;
    }
    return _priceLab;
}

@end
